package br.com.character.flex.chorm.core.annotation
{
    [Bindable]
    public class Annotation implements IAnnotation
    {
        private var _name:String;
        private var _attributes:Vector.<IAttribute>;
        public function Annotation(n:String=null)
        {
            _name = n;
        }
        
        public function get name():String
        {
            return _name;
        }
        
        public function set name(param:String):void
        {
            _name = param;
        }
        
        public function get attributes():Vector.<IAttribute>
        {
            if(_attributes==null){
                _attributes = new Vector.<IAttribute>();       
            }
            return _attributes;
        }
        
        public function set attributes(param:Vector.<IAttribute>):void
        {
            _attributes = param;
        }
        
        public function addAttribute(param:IAttribute):void
        {
            _attributes.push(param);
        }
        
        public function toString():String{
            var result: String = super.toString();
            if(name!=null && attributes!=null && attributes.length > 0){
                result = name;
                for each(var attr: IAttribute in attributes){
                    result += attr.name + " = " + attr.value;
                }
            }
            return result;
        }
    }
}